<?php defined('SYSPATH') or die('No direct script access.');

class Model_Category extends ORM {
	// contain many relationship
	protected $_has_many = array(
		// a category has many attributes
		'attributes' => array(
			'model' => 'attribute',
			'foreign_key' => 'category_id'
		),
		'subcategories' => array(
			'model' => 'category',
			'foreign_key' => 'parent_category_id'
		),
		'items' => array(
			'model' => 'item',
			'foreign_key' => 'category_id',
		),
	);
		
	protected $_belongs_to = array(
		// a subcategory belongs to a category
		'parent_category' => array(
			'model' => 'category',
			'foreign_key' => 'parent_category_id'
		)
	);
}
